<?php
	include('dbconnect.php');
	require_once('class.Fitness.php');
	require_once('class.UserDB.php');
  	
	$fitness = new Fitness();
	$userDB = new UserDB();
    $xmlData = file_get_contents("http://www.ashkansotoudeh.com/blog/?feed=rss2");
	$xmlData = str_replace("content:encoded","content",$xmlData);
	$xmlData = str_replace("dc:creator","creator",$xmlData);
	$xml = new SimpleXMLElement($xmlData);
	$item = $xml->channel;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
	<link rel="Icon" href="favicon.ico" />
    <link rel="Stylesheet" type="text/css" media="screen" href="style.css" />
    <title><?php $config->displayHeader(); ?></title>
</head>
<body>
    <div id="header">
		<div id="navigation">
    	<a id="navitem" href="index.php">Home</a> |
    	<a id="navitem" href="codeSnippets.php">Code Snippets</a> |
		<a id="navitem" href="/blog">Blog</a> |
    	<a id="navitem" href="rss.php">RSS Feed</a> |
		<a id="navitem" href="about.php">About Me</a> |
		<?php if (!isset($_SESSION['fName'])) { ?>
			<a id="navitem" href="login.php">Login</a> |
		<?php } else { ?>
			<a id="navitem" href="admin.php">Admin</a>
		<?php } ?>
		</div>
		<h1 class="title"><a class="title" href="index.php"><?php $config->displayHeader(); ?></a></h1>
		<h3 class="quote"><?php $config->displayQuote(1); ?></h3>
	</div>
	
	<div id="sidebar">Recent Posts
		<div id="sidebardata">
		<?php
		foreach ($item->item as $post) {
			$postTitle = $post->title;
			echo "<a id='sidebardata' href='#$postTitle'>" . $postTitle . "</a><br \>";
		}
		?>
		</div>
	</div>
	<div id="sidebar2">Links
		<div id="sidebardata">
			<a id='sidebardata' href="http://cs.senecac.on.ca/">CS Seneca</a><br />
			<a id='sidebardata' href="http://my.senecacollege.ca/">My Seneca</a><br />
			<a id='sidebardata' href="https://learn.senecac.on.ca/">Learn Email</a><br />
			<a id='sidebardata' href="http://cdot.senecac.on.ca/">CDOT</a><br />
			<a id='sidebardata' href="http://webchat.freenode.net?channels=seneca&uio=d4">Freenode IRC</a>
			</div>
	</div>
    <div id="content">
	<?php
    function highlight_file_with_line_numbers($file) {
          //Strip code and first span
        $code = substr(highlight_file($file, true), 36, -15);
        //Split lines
        $lines = explode('<br />', $code);
        //Count
        $lineCount = count($lines);
        //Calc pad length
        $padLength = strlen($lineCount);
       
        //Re-Print the code and span again
        echo "<code><span style=\"color: #000000\">";
       
        //Loop lines
        foreach($lines as $i => $line) {
            //Create line number
            $lineNumber = str_pad($i + 1,  $padLength, '0', STR_PAD_LEFT);
            //Print line
            echo sprintf('<span style="color: #999999">%s| </span>%s', $lineNumber, $line);
        }
       
        //Close span
        echo "</span></code>";
    }

highlight_file_with_line_numbers('code.txt');
?>
    </div>
	<div id="footer">
    	<a href="#">About</a> - <a href="#">Contact Us</a> - <a href="#">Help</a>
    	<br />
    	<?php $config->displayFooter(); ?>
    </div>
</body>
</html>